package org.aplikator.client.descriptor;

import java.util.ArrayList;
import java.util.List;

import org.aplikator.client.widgets.FormWidget;
import org.aplikator.client.widgets.PaneWidget;

import com.google.gwt.user.client.ui.Widget;

@SuppressWarnings("serial")
public class PanelDTO implements WidgetDTO {

    private List<WidgetDTO> children = new ArrayList<WidgetDTO>();
    private boolean frame = false;
    private boolean vertical = false;

    @SuppressWarnings("unused")
    private PanelDTO(){}

    public PanelDTO(boolean vertical) {
        this.vertical = vertical;
    }

    public Widget getWidget(FormWidget form) {
        PaneWidget pane = new PaneWidget(null, frame, vertical);
        for (WidgetDTO childDescriptor : children) {
            pane.add(childDescriptor.getWidget(form));
        }
        return pane;
    }

    public PanelDTO addChild(WidgetDTO child) {
        children.add(child);
        return this;
    }

    public void setFrame(boolean frame) {
        this.frame = frame;
    }

    public boolean isFrame() {
        return frame;
    }

}
